package com.lywz.biz.service.food.impl;

import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import com.lywz.biz.common.dao.CommonDao;
import com.lywz.biz.common.entity.goodfood.FoodType;
import com.lywz.biz.dao.food.FoodTypeDao;
import com.lywz.biz.service.food.FoodTypeService;
import com.lywz.core.exception.ExceptionMes;
import com.lywz.core.exception.SSException;
@Service("foodTypeService")
public class FoodTypeServiceImpl implements FoodTypeService {

    @Autowired
    private CommonDao commonDao;
    
    @Autowired
    private FoodTypeDao foodTypeDao;

    @Override
    public String getFoodTypeDescById(int foodTypeId) throws SSException {

        try {
            String foodTypeDesc = foodTypeDao.getDescriptionById(foodTypeId);
            if (foodTypeDesc != null) {
                return foodTypeDesc;
            }
            return null;
        } catch (Exception e) {
            e.printStackTrace();
            throw SSException.get(ExceptionMes.SYSEXCEPTION);
        }
    }

    @Override
    public FoodType getOneFoodType(Integer foodTypeId) throws SSException {
        try {
            FoodType foodType = commonDao.queryById(FoodType.class, foodTypeId);
            return foodType;
        } catch (Exception e) {
            e.printStackTrace();
            throw SSException.get(ExceptionMes.SYSEXCEPTION);
        }
    }

}
